TransformRect = {

}

rect_transform_resolution = {width=0,height=0} --建议名字长点防止重复

function TransformRect.setResolution(resolution)

  rect_transform_resolution.width = resolution[1]
  rect_transform_resolution.height = resolution[2]

end
function Rect:transform(x,y,width,height)
      return {x/rect_transform_resolution.width,y/rect_transform_resolution.height,width/rect_transform_resolution.width,height/rect_transform_resolution.height}
end
-- function Rect:transform(x,y,width,height)
--   local ratio = self:is9to16() and 1.0 or 4.0/3.0

--   self.x = (x - 540.0) / 540.0
--   self.y = (y - 720.0) / 960.0
--   self.width = width*2 / 1080.0
--   self.height = height*2*ratio / 1920.0 --*ratio保证了16:9下和4:3下的高度相同
--   return {self.x,self.y,self.width,self.height}
-- end
-- function Rect:is9to16()
--   local ratio = self.res.x/self.res.y

--   if ratio > 0.5 and ratio < 0.6 then
--       return true
--   end

--   return false
-- end